<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp"%>
<script type="text/javascript">
$(function(){
	$("#pager").pager({ pagenumber: ${pageModel.currentPage}, 
						pagecount: ${pageModel.totalPage},
						buttonClickCallback: function(page){
							$("#content_detail").load("messageInner.htm?page="+page);
						} 
	});
	$.metadata.setType("attr","validate");
	$("#my_family_message_no_read").text('${messageNoRead}');
});

function deleteMessage(messageId){
	$("#content_detail").load("messageInnerDelete.htm",{
		"messageId":messageId
	},function(){
		operateTip('message_delete_tip_success');
	});
}

function messageReplyDialog(messageId,receiveFamily){
		$(".h_replyText_box").hide();
		$("#message_inner_reply_"+messageId).show();
}

function messageReply(messageId,receiveFamily,page){
	if($("#replay_message_form_"+messageId).valid()){
		$("#content_detail").load("replyMessage.htm",{
			receiveFamily:receiveFamily,
			replyId:messageId,
			content:$("#replay_message_content_"+messageId).val(),
			page:page
		},function(data){
			operateTip("message_reply_tip_success");
		});
	}
}
	
</script>

<div class="h_main2">
	<div class="h_data">
		<h2>
			信息
		</h2>
		<div class="h_newNews">
			<ul>

				<li id="newNews2" onclick="message();">
					<a>邻居邀请(${messageFriendNoRead})</a>
				</li>
				<li id="newNews3" class="h_newNewsHover">
					<a>站内信息(${messageInnerNoRead})</a>
				</li>
				<div class="clear"></div>
			</ul>
			<div class="clear"></div>
		</div>
		<div id="message_content">

			<div class="h_newNews_box">
				<div class="success" id="message_delete_tip_success"
					style="display: none;">
					<img alt="删除成功" src="images/home_images/ico29.png" />
					删除消息成功
				</div>
				<div class="success" id="message_reply_tip_success"
					style="display: none;">
					<img alt="回复成功" src="images/home_images/ico29.png" />
					回复消息成功
				</div>
				<c:choose>
					<c:when test="${pageModel.totalPage < 1}">
						<div style="margin-left: 10px; margin-top: 20px;">
							您的站内目前没有消息
						</div>

					</c:when>
					<c:otherwise>
						<div class="h_newNews_text" id="con_newNews_1"
							style="display: block;">

							<div class="h_invitefriends_list pt10">
								<ul>
									<c:forEach items="${pageModel.list}" var="msgExt">
										<c:choose>
											<c:when test="${msgExt.familyId==member.family}">
												<li>
													<span><fmt:formatDate value="${msgExt.gmtModified}"
															pattern="yyyy-MM-dd HH:mm" /> </span>
													<a href="#" title="进入他的家"
														onclick="seeOtherFamily('${msgExt.receiveFamily}')"><img
															width="58" height="58" src="${msgExt.familyAvatar}"
															alt="头像" /> </a>
													<em><c:out value="${msgExt.familyNickname}" />
													</em>
													<p class="h_invitefriends_name">
														<c:choose>
															<c:when test="${msgExt.sendMember==member.identifier}">
																<a href="javascript:void(0);">你</a>
															</c:when>
															<c:otherwise>
																<a href="javascript:void(0);"><c:out
																		value="${msgExt.sendUsername}" />
																</a>
															</c:otherwise>
														</c:choose>
														对
														<a href="javascript:void(0);"><c:out
																value="${msgExt.receiveFamilyNickname}" />
														</a> “说到”：
														<c:out value="${msgExt.content}" />
													</p>
													<div class="h_invitefriends_reply">
														<div class="h_reply_box">
															<a href="javascript:void(0);"
																onclick="deleteMessage('${msgExt.identifier}');">删除</a>
														</div>
														<div class="clear"></div>

													</div>
													<div class="clear"></div>
												</li>
											</c:when>
											<c:otherwise>
												<li>
													<span><fmt:formatDate value="${msgExt.gmtModified}"
															pattern="yyyy-MM-dd HH:mm" /> </span>
													<a href="#" title="进入他的家"
														onclick="seeOtherFamily('${msgExt.familyId}')"><img
															width="58" height="58" src="${msgExt.familyAvatar}"
															alt="头像" /> </a>
													<em><c:out value="${msgExt.familyNickname}" />
													</em>
													<p class="h_invitefriends_name">
														<a href="#"
															onclick="seeOtherFamily('${msgExt.familyId}')"><c:out
																value="${msgExt.sendUsername}" />
														</a> 对
														<a href="javascript:void(0);">你家</a> “说到”：
														<c:out value="${msgExt.content}" />
													</p>
													<div class="h_invitefriends_reply">
														<div class="h_reply_box">
															<a href="javascript:void(0);"
																onclick="messageReplyDialog('${msgExt.identifier}','${msgExt.familyId}')">回复</a><em>|</em>
															<a href="#"
																onclick="deleteMessage('${msgExt.identifier}');">删除</a>
														</div>
														<div class="clear"></div>
														<div class="h_replyText_box"
															id="message_inner_reply_${msgExt.identifier}"
															style="height: 120px;">
															<form action=""
																id="replay_message_form_${msgExt.identifier}">
																<div class="h_replyText_top"></div>
																<div class="h_replyText_text">
																	<h4>
																		<a href="javascript:void(0);"
																			onclick="$('#message_inner_reply_${msgExt.identifier}').hide();">
																			<img src="images/home_images/delete.gif" alt="删除"
																				title="删除" /> </a>评论原文
																	</h4>
																	<div class="h_replyText_area">
																		<textarea name="replyMessageContent"
																			id="replay_message_content_${msgExt.identifier}"
																			cols="" rows=""
																			validate="{required:true,maxlength:1000,messages:{required:'回复消息不能为空',maxlength:'长度不能超过1000个字符'}}"></textarea>
																	</div>
																	<div class="h_button fr mt5 mr25"
																		onclick="messageReply('${msgExt.identifier}','${msgExt.familyId}','${pageModel.currentPage}')">
																		<strong>回 复</strong>
																	</div>
																</div>
															</form>
															<script type="text/javascript">
$("#replay_message_form_${msgExt.identifier}").validate();
</script>
														</div>

													</div>
													<div class="clear"></div>
													<c:forEach items="${msgExt.replyMessageList}"
														var="replyMessage">
														<div class="h_replyText2">
															<a href="#" title="进入他的家"><img
																	src="${replyMessage.familyAvatar}" width="58"
																	height="58" alt="头像" />
															</a>
															<em><c:out value="${replyMessage.familyNickname}" />
															</em>
															<p class="h_invitefriends_name">
																<c:choose>
																	<c:when
																		test="${replyMessage.sendMember==member.identifier}">
																		<a href="javascript:void(0);">你</a>
																	</c:when>
																	<c:otherwise>
																		<a href="javascript:void(0);"><c:out
																				value="${replyMessage.sendUsername}" />
																		</a>
																	</c:otherwise>
																</c:choose>
																对
																<a href="javascript:void(0);"><c:out
																		value="${replyMessage.receiveFamilyNickname}" />
																</a> 说到：
																<c:out value="${replyMessage.content}" />
															</p>
															<div class="h_reply_box">
																<a href="#"
																	onclick="deleteMessage('${replyMessage.identifier}');">删除</a>
															</div>
															<div class="clear"></div>
														</div>
													</c:forEach>


												</li>
											</c:otherwise>
										</c:choose>

									</c:forEach>
								</ul>

								<div class="clear"></div>

								<div class="h_page" id="pager"></div>
							</div>

							<div class="h_newNews_text" id="con_newNews_2"></div>
							<div class="h_newNews_text" id="con_newNews_3">
								fdsfsdf
							</div>
							<div class="clear"></div>
						</div>
					</c:otherwise>
				</c:choose>


				<div class="clear"></div>
			</div>


		</div>
	</div>
</div>


